package PlugIn;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;

import FilePanel.Data;

/**
 * @author      Erwan Osouf, Lucas Ennouchi
 * @version     1.0                                
 * @since       29/01/2012
 */

public abstract class PlugInModel {
	
	private Data data;
	
	/**
	 * constrcutor
	 * @param data
	 */
	public PlugInModel(Data data) {
		super();
		this.data = data;
	}



	/**
	 * runs the plugin
	 */
	public final void run(){
		ArrayList<File> sample = getData().getSelectedFiles();
		System.out.println(sample);
		switch(sample.size()){
		case 0 : manageEmpty();break;
		case 1 : 
			File f = sample.get(0);
			if(f.isFile()){
				manageFile(f);
			}
			else{
				manageDir(f);
			}
			break;
		default : manageMultiple(sample);break;
		}
	}
	
	/**
	 * gets the data
	 * @return data the data is returned
	 */
	private Data getData() {
		return data;
	}

	

	public abstract String getName();
	
	protected abstract void manageEmpty();
	
	protected abstract void manageFile(File f);

	protected abstract void manageDir(File f);

	protected abstract void manageMultiple(Collection<File> lf);
	
	public abstract String getResult();
	
}
